﻿using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

public class GameInfoView : MonoBehaviour
{

    public List<GameObject> Infos;

    public GameObject HelpInfo;

    public Button Close;
    private int _index;
    void OnEnable()
    {
        _index = 0;
        HelpInfo.SetActive(false);
        Close.onClick.AddListener(() =>
        {
            Destroy(gameObject);
        });
        for (int i = 0; i < Infos.Count; i++)
        {
            Infos[i].SetActive(false);
            Infos[i].transform.localPosition = new Vector2(Infos[i].transform.localPosition.x, Infos[i].transform.localPosition.y + 64);
        }
        StartCoroutine(StartInfos());
    }

    IEnumerator StartInfos()
    {
        for (_index = 0; _index < Infos.Count; _index++)
        {
            Infos[_index].SetActive(true);
            Infos[_index].transform.DOLocalMoveY(Infos[_index].transform.localPosition.y - 64, 0.5f);
            yield return new WaitForSeconds(1.5f);
        }
        for (int i = 0; i < Infos.Count; i++)
        {
            Infos[i].SetActive(false);
            Infos[i].transform.localPosition = new Vector2(Infos[i].transform.localPosition.x, Infos[i].transform.localPosition.y + 64);
        }
        HelpInfo.SetActive(true);

    }
}
